import 'package:baby_book_bloc/hive_db/models/baby_info.dart';
import 'package:hive/hive.dart';

class BabyInfoAdapter extends TypeAdapter<BabyInfo> {
  @override
  BabyInfo read(BinaryReader reader) {
    return BabyInfo(
      babyName: reader.read(),
      babySex: reader.read(),
      babyBrit: reader.read(),
      babyStature: reader.read(),
      babyWeight: reader.read(),
      upDateTimeAt: reader.read(),
    );
  }

  @override
  final int typeId = 0;

  @override
  void write(BinaryWriter writer, BabyInfo obj) {
    writer
      ..write(obj.babyName)
      ..write(obj.babySex)
      ..write(obj.babyBrit)
      ..write(obj.babyStature)
      ..write(obj.babyWeight)
      ..write(obj.upDateTimeAt);
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is BabyInfoAdapter &&
          runtimeType == other.runtimeType &&
          typeId == other.typeId;
}
